package com.thor.palmmall.rest.order.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.order.AProductProm;
import com.thor.palmmall.spi.order.SProductProm;

public class AProductPromConverter implements Converter<SProductProm, AProductProm> {
	private static AProductPromConverter instance;
	public static AProductPromConverter getInstance() {
		if (instance == null)
			instance = new AProductPromConverter();
		return instance;
	}

	private AProductPromConverter() {
	}

	@Override
	public AProductProm convert(SProductProm source) {
		if (source == null) {
			return null;
		}
		AProductProm target = new AProductProm();
		target.setActivityId(source.getActivityId());
		target.setPromotionUuid(source.getPromotionUuid());
		target.setActivityName(source.getActivityName());
		target.setActivityType(source.getActivityType());
		target.setSegmentType(source.getSegmentType());
		target.setContract(UCN.newInstance(source.getContract()));
		target.setTenant(UCN.newInstance(source.getTenant()));
		target.setShops(source.getShops());
		target.setBeginTime(source.getBeginTime());
		target.setEndTime(source.getEndTime());
		target.setDiscountRate(source.getDiscountRate());
		target.setCutAmount(source.getCutAmount());
		target.setMinConsumptionAmount(source.getMinConsumptionAmount());
		target.setMaxVoucherAmount(source.getMaxVoucherAmount());
		target.setSegments(source.getSegments());
		return target;
	}

}
